package com.jlcon.nas.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.jlcon.nas.biz.aria.AriaClient;
import com.jlcon.nas.utils.CommonDataResponse;
import com.jlcon.nas.utils.CommonResponse;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("boss/download")
@Tag(name = "下载管理")
@RequiredArgsConstructor
public class DownloadBossController {
	
	private final AriaClient ariaClient;

	@PostMapping(value = "aria-active")
    @Operation(summary ="下载列表")
    public CommonDataResponse<?> commonDataResponseResult() throws Throwable {
        return CommonDataResponse.buildSuccessResult(ariaClient.tellActive());
    }
	
	@PostMapping(value = "download-file")
	@Operation(summary = "下载文件测试")
	public CommonResponse testDownload(String magnet) throws Throwable {
		String gid = ariaClient.addUri(magnet);
		return CommonResponse.buildSuccessResult(gid);
	}
	
	@PostMapping(value = "force-remove")
	@Operation(summary = "删除任务")
	public CommonResponse forceRemove(@RequestBody String[] gid) throws Throwable {
		ariaClient.forceRemove(gid);
		return CommonResponse.buildSuccessResult();
	}
}